import { lazy } from "react";
import { createBrowserRouter, Navigate } from "react-router-dom";
import { AppstoreAddOutlined, AppstoreOutlined, HomeOutlined, SettingOutlined, ToolOutlined, UserOutlined } from "@ant-design/icons";
 
// 懒加载Home组件
const Home = lazy(() => import("../pages/Home/index"));
 
// 懒加载Login组件
const Login = lazy(() => import("../pages/Login/index"));
 
// 懒加载Set组件
const Set = lazy(() => import("../pages/Set/index"));
 
// 懒加载My组件
const My = lazy(() => import("../pages/My/index"));
 
// 懒加载Layout组件
const Layout = lazy(() => import("../pages/Layout/index"));
 
// 懒加载Numpeo组件
const Numpeo = lazy(() => import("../pages/Numpeo/index"));
 
// 懒加载Qita组件
const Qita = lazy(() => import("../pages/Qita/index"));
 
// 懒加载Devp组件
const Devp = lazy(()=>import("../pages/Devp/index"));
 
// 懒加载Bus组件
const Bus = lazy(()=>import("../pages/Bus/index"));
 
// 子路由配置数组
export const router_child = [
  {
    path: "/home",
    element: <Home />,
    title: "首页",
    icon: <HomeOutlined />,
  },
  {
    path: "/devp",
    element: <Devp />,
    title: "部门管理",
    icon: <AppstoreOutlined />,
  },
  {
    path: "/bus",
    element: <Bus />,
    title: "业务管理",
    icon: <AppstoreAddOutlined />
  },
    {
    path: "/qita",
    element: <Qita />,
    title:"其他",
     icon:<ToolOutlined />
  },
  {
    path: "/set",
    element: <Set />,
    title: "设置",
    icon: <SettingOutlined />,
    children: [
      {
        path: "/set/my",
        element: <My />,
        title: "我的",
        icon: <UserOutlined />,
      },
    ],
  },
];
 
// 创建浏览器路由
const routes = createBrowserRouter([
  {
    path: "/",
    element: <Layout></Layout>,
    children: [
      { index: true, element: <Navigate to="/login" /> }, // 添加默认重定向
      ...router_child
    ],
  },
  {
    path: "/login",
    element: <Login />,
  },
  {
    path: "/numpeo",
    element: <Numpeo />,
  },

]);
 
// 导出路由配置
export default routes;
